package com.dw.model.user;

import java.util.Date;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import lombok.Data;


@Data
public class User {
    private int id;
    private int doctorId;
    private int patientId;

    private String username;
    private String password;
    private String role;

    private Date createTime;

    private Set<String> permissions = new HashSet<>();

    public User() {}

    public User(String username, String password, String role) {
        this.username = username;
        this.password = password;
        this.role = role;
    }

    @Override
    public String toString() {
        return username;
    }

    public boolean isAdmin() {
        return Objects.equals(role, "doctor");
    }

    public boolean hasPermission(String permissionKey) {
        return permissions != null && permissions.contains(permissionKey);
    }
}